
from pages.base_page import BasePage
from selenium.webdriver.common.by import By


class CustomerRecycleBinPage(BasePage):
    url = "/crm/index.php?m=customer&a=index&by=deleted"
    result_locator = (By.XPATH, '/html/body/div[5]/div[2]')
    error_locator =(By.XPATH,"/html/body/div/form/fieldset/div[1]")
    choose_all_locator = (By.ID, 'check_all')  # 选择全部
    batch_locator = (By.CSS_SELECTOR,'body > div.container > div.row > div:nth-child(1) > ul > div > a')    # 批量操作
    batch_delete_locator = (By.ID,'delete')     # 批量删除
    choose_first_locator=(By.XPATH,'//*[@id="form1"]/table/tbody/tr[1]/td[1]/input')
    def click_choose_first(self):
        """
        点击选择全部
        """
        self.find_element(self.choose_first_locator).click()


    def click_choose_all(self):
        """
        点击选择全部
        """
        self.find_element(self.choose_all_locator).click()

    def click_batch(self):
        """
        点击批量操作
        :return: None
        """
        self.find_element(self.batch_locator).click()

    def click_batch_delete(self):
        """
        点击批量删除
        :return: None
        """
        self.find_element(self.batch_delete_locator).click()

#返回增删改查后的提示信息
    def get_result_tips(self):
        return self.find_element(self.result_locator).text

#返回弹窗文本信息
    def get_alert_text(self):
        return self.driver.switch_to.alert.text

#返回报错弹窗文本信息
    def get_error_text(self):
        return self.find_element(self.error_locator).text

